package com.ruoyi.web.controller.datastatistics;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.datastatistics.domain.ElectricityRealtimegatherdataXb;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.datastatistics.service.IElectricityRealtimegatherdataXbService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电-实时数据Controller
 * 
 * @author gdqt
 * @date 2025-03-10
 */
@RestController
@RequestMapping("/datastatistics/electricityRealtimegatherdata")
public class ElectricityRealtimegatherdataXbController extends BaseController
{
    @Autowired
    private IElectricityRealtimegatherdataXbService electricityRealtimegatherdataXbService;

    /**
     * 查询实时数据采集（小）列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ElectricityRealtimegatherdataXb realtimegatherdataXb)
    {
        startPage();
        List<ElectricityRealtimegatherdataXb> list = electricityRealtimegatherdataXbService.selectList(realtimegatherdataXb);
        return getDataTable(list);
    }

    /**
     * 导出实时数据采集（小）列表
     */
    @Log(title = "实时数据采集（小）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElectricityRealtimegatherdataXb realtimegatherdataXb)
    {
        List<ElectricityRealtimegatherdataXb> list = electricityRealtimegatherdataXbService.selectList(realtimegatherdataXb);
        ExcelUtil<ElectricityRealtimegatherdataXb> util = new ExcelUtil<ElectricityRealtimegatherdataXb>(ElectricityRealtimegatherdataXb.class);
        util.exportExcel(response, list, "实时数据采集（小）数据");
    }

    /**
     * 获取实时数据采集（小）详细信息
     */
    @GetMapping(value = "/{TerminalID}")
    public AjaxResult getInfo(@PathVariable("TerminalID") String TerminalID)
    {
        return success(electricityRealtimegatherdataXbService.selectRealtimegatherdataXbByTerminalID(TerminalID));
    }

    /**
     * 新增实时数据采集（小）
     */
    @Log(title = "实时数据采集（小）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElectricityRealtimegatherdataXb realtimegatherdataXb)
    {
        return toAjax(electricityRealtimegatherdataXbService.insertRealtimegatherdataXb(realtimegatherdataXb));
    }

    /**
     * 修改实时数据采集（小）
     */
    @Log(title = "实时数据采集（小）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElectricityRealtimegatherdataXb realtimegatherdataXb)
    {
        return toAjax(electricityRealtimegatherdataXbService.updateRealtimegatherdataXb(realtimegatherdataXb));
    }

    /**
     * 删除实时数据采集（小）
     */
    @Log(title = "实时数据采集（小）", businessType = BusinessType.DELETE)
    @DeleteMapping("/{TerminalIDs}")
    public AjaxResult remove(@PathVariable String[] TerminalIDs)
    {
        return toAjax(electricityRealtimegatherdataXbService.deleteRealtimegatherdataXbByTerminalIDs(TerminalIDs));
    }
}
